package com.ruoyi.web.controller.system;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Zhijian;
import com.ruoyi.system.service.IZhijianService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


/**
 * 质检服务内容Controller
 *
 * @author ruoyi
 * @date 2021-05-27
 */
@RestController
@RequestMapping("/super/zhijian")
public class ZhijianController extends BaseController
{
    @Autowired
    private IZhijianService zhijianService;

    /**
     * 查询质检服务内容列表
     */

    @GetMapping("/list")
    public TableDataInfo list(Zhijian zhijian)
    {
        startPage();
        List<Zhijian> list = zhijianService.selectZhijianList(zhijian);
        return getDataTable(list);
    }

    /**
     * 导出质检服务内容列表
     */

    @Log(title = "质检服务内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Zhijian zhijian)
    {
        List<Zhijian> list = zhijianService.selectZhijianList(zhijian);
        ExcelUtil<Zhijian> util = new ExcelUtil<Zhijian>(Zhijian.class);
        return util.exportExcel(list, "zhijian");
    }

    /**
     * 获取质检服务内容详细信息
     */

    @GetMapping(value = "/{zhijianId}")
    public AjaxResult getInfo(@PathVariable("zhijianId") Long zhijianId)
    {
        return AjaxResult.success(zhijianService.selectZhijianById(zhijianId));
    }

    /**
     * 新增质检服务内容
     */

    @Log(title = "质检服务内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Zhijian zhijian)
    {
        return toAjax(zhijianService.insertZhijian(zhijian));
    }

    /**
     * 修改质检服务内容
     */

    @Log(title = "质检服务内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Zhijian zhijian)
    {
        return toAjax(zhijianService.updateZhijian(zhijian));
    }

    /**
     * 删除质检服务内容
     */

    @Log(title = "质检服务内容", businessType = BusinessType.DELETE)
    @DeleteMapping("/{zhijianIds}")
    public AjaxResult remove(@PathVariable Long[] zhijianIds)
    {
        return toAjax(zhijianService.deleteZhijianByIds(zhijianIds));
    }
}
